'use strict';
import * as Koa from 'koa';
import { router, prefix } from '../middleware/router';
import { response } from '../middleware/result';
import { gameService } from '../service/game';
import { logService } from '../service/log';

/** 活动设置API */
@prefix('game')
class GameController {
    @router('/query', { method: 'post' })
    async query(ctx: Koa.Context) {
        let result = await gameService.query(ctx.request.body);
        response(ctx, result);
    }
    @router('/save', { method: 'post' })
    async save(ctx: Koa.Context) {
        let result = await gameService.save(ctx.request.body);
        response(ctx, result);
    }
    @router('/queryById/:id')
    async queryById(ctx: Koa.Context) {
        let result = await gameService.queryById(ctx.params.id);
        response(ctx, result);
    }
    @router('/open/:id')
    async open(ctx: Koa.Context) {
        let result = await gameService.open(ctx.params.id);
        response(ctx, result);
    }
    @router('/lock/:id')
    async lock(ctx: Koa.Context) {
        let result = await gameService.lock(ctx.params.id);
        response(ctx, result);
    }
    @router('/querygame')
    async querygame(ctx: Koa.Context) {
        // 记录回调日志
        logService.createlogger(ctx, 0);
        let result = await gameService.querygame(ctx.query.token);
        response(ctx, result);
    }
}